-- ========================= Consulta as Saidas de NFs ==================== --
SELECT A.FILIAL, A.NF_SAIDA, A.EMISSAO,B.CODIGO_FISCAL_OPERACAO,
B.CODIGO_ITEM, B.ID_EXCECAO_IMPOSTO, A.NATUREZA_SAIDA
FROM FATURAMENTO A, FATURAMENTO_ITEM B
WHERE A.FILIAL = B.FILIAL
AND A.NF_SAIDA = B.NF_SAIDA
AND A.FILIAL LIKE '105%'
AND B.ID_EXCECAO_IMPOSTO = '16'
--AND A.NF_SAIDA = '001557'
AND A.EMISSAO >= '20060501'
ORDER BY A.NF_SAIDA, B.CODIGO_ITEM

-- ========================= Alterar as Saidas de NFs ==================== --

UPDATE B SET ID_EXCECAO_IMPOSTO = '116'
FROM FATURAMENTO A, FATURAMENTO_ITEM B
WHERE A.FILIAL = B.FILIAL
AND A.NF_SAIDA = B.NF_SAIDA
AND A.FILIAL LIKE '105%'
--AND A.NF_SAIDA = '001557'
AND B.ID_EXCECAO_IMPOSTO = '16'
AND A.EMISSAO >= '20060501'
